package com.lagou.numbersort.step1;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Partitioner;

public class NumSortPartitioner extends Partitioner<LongWritable, NullWritable> {
    //按数字的大小进行分区
    @Override
    public int getPartition(LongWritable key, NullWritable nullWritable, int i) {
        if (key.get()<500){
            return 0;
        }else if (key.get()>=500 && key.get()<=1000){
            return 1;
        }else {
            return 2;
        }
    }
}
